[No QA] Embed coding-standards in reviewer subagent prompt for stable prompt caching #93661
Draft
kacper-mikolajczak wants to merge 1 commit into
Draft
[No QA] Embed coding-standards in reviewer subagent prompt for stable prompt caching #93661kacper-mikolajczak wants to merge 1 commit into
kacper-mikolajczak wants to merge 1 commit into
Conversation
6f18c30 to
6262af6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation of Change
The Claude PR reviewer dispatches a
code-inline-reviewersubagent whose definition instructs it toGlobandReadall 28 coding-standards rule files on every run. Those reads land in the conversation (message) layer, beneath a per-checkout system prompt, so the ~25K-token ruleset is never a byte-stable, cacheable prefix: it is re-paid at the prompt-cache write rate on every PR run, and ~29 extra tool round-trips are spent just loading it.This PR moves the ruleset into the subagent's system prompt so it becomes a deterministic, cacheable prefix:
.claude/skills/coding-standards/build-reviewer-agent.mjs— a deterministic compiler that embeds every rule file (sorted, checksummed, no timestamps) into the subagent definition. Same inputs produce byte-identical output, which is what prompt-cache prefix hits require..claude/skills/coding-standards/code-inline-reviewer.template.md— the source template. The only change vs. the previous agent definition is that the "load all rules" step is replaced by the embedded ruleset plus an injection marker; all other wording, the comment format, and the output schema are preserved byte-for-byte..claude/agents/code-inline-reviewer.mdwith all 28 rules embedded, so the subagent no longer Globs/Reads them at runtime..github/workflows/claude-review.yml: adds--exclude-dynamic-system-prompt-sectionsso per-run system-prompt sections (cwd, git state, OS) stop invalidating the prefix, and adds a CI step that runs the compiler with--checkto fail fast if a rule file changes without regenerating the agent definition.Net effect: the rule corpus is loaded once per run instead of via ~29 tool calls, and the now byte-stable prefix becomes eligible for cross-run prompt-cache reads (0.1x) instead of writes (1.25x) when runs fall within the cache TTL. Reviewer behavior is unchanged — the same rules are enforced.
Fixed Issues
$ #93665
PROPOSAL:
Tests
This change affects the CI reviewer tooling only — no app runtime or UI. To verify locally from the repo root:
node .claude/skills/coding-standards/build-reviewer-agent.mjsand verify it regenerates.claude/agents/code-inline-reviewer.mdwith all 28 rules embedded (a### Rule indextable with 28 rows and a closing</coding-standards>tag).node .claude/skills/coding-standards/build-reviewer-agent.mjs --out /tmp/a.md && node .claude/skills/coding-standards/build-reviewer-agent.mjs --out /tmp/b.md && cmp /tmp/a.md /tmp/b.md.node .claude/skills/coding-standards/build-reviewer-agent.mjs --checkand verify it exits0when the committed agent definition is up to date..claude/skills/coding-standards/rules/, run--checkagain, and verify it exits non-zero (stale detected). Revert the edit..github/workflows/claude-review.ymlis valid YAML and that theRun Claude Code (code)step'sclaude_argsincludes--exclude-dynamic-system-prompt-sections.Offline tests
N/A — this change only affects CI reviewer tooling and does not touch network, API, or Onyx code.
QA Steps
N/A — CI/tooling change with no user-facing or staging-testable behavior. Title includes
[No QA].PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari